package com.navinfo.platform.dataanalysis.dto;

import com.navinfo.platform.common.dto.DataInfo;
import lombok.Data;
import org.apache.spark.sql.Row;

import java.io.Serializable;

@Data
public class RealtimeDataDto implements DataInfo, Serializable {
    private long tid;
    private long gpsDate;
//    private int engineoutputtorque;
    private int speed;
    private int rotation;
    private int accPedalPos;
    private int brake;
    private int clutchSwitch;
    private int acc;


    public static DataInfo parseRow(Row row){
        RealtimeDataDto realtimeDataDto = new RealtimeDataDto();
        realtimeDataDto.setTid(Long.parseLong(row.getAs("tid")));
        realtimeDataDto.setGpsDate((Long.parseLong(row.getAs("gpstime"))/1000));
        realtimeDataDto.setBrake(Integer.parseInt(row.getAs("brake"))/100);
        realtimeDataDto.setAccPedalPos(Integer.parseInt(row.getAs("accelerator"))/100);
        realtimeDataDto.setRotation(Integer.parseInt(row.getAs("rotation"))/100);
        realtimeDataDto.setSpeed(Integer.parseInt(row.getAs("speed"))/100);
        realtimeDataDto.setClutchSwitch(Integer.parseInt(row.getAs("clutchSwitch"))/100);
//        realtimeDataDto.setEngineoutputtorque(Integer.parseInt(row.getAs("engineoutputtorque"))/100);
        return realtimeDataDto;
    }
}
